<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>

    .switch-inner{
      display: inline-block;
      width: 40px;
      height: 20px;
      border-radius: 10px;
      background-color: #FF4949;
    }
    .switch-inner::after{
      display: block;
      content: '';
      width: 18px;
      height: 18px;
      border-radius: 50%;
      background-color: white;
      margin-left: 1px;
      margin-top: 1px;
      /* 过渡动画，元素发生改变时的过渡 */
      transition: all 0.3s;
    }
    input[type="checkbox"]:checked + span::after{
      margin-left: 21px;
    }
    input[type="checkbox"]:checked + span{
      background-color: #13CE66;
    }
    .switch > input[type="checkbox"]{
      /* 隐藏 */
      display: none;
    }
  </style>
</head>
<body>
  <!-- 
      label标签： 可以扩大用户的点击范围
           点击label区域相当于点击其内部的表单控件
  -->
  <label class="switch">
    <input type="checkbox">
    <span class="switch-inner"></span>
  </label>
</body>
</html>